/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boot;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONObject;

/**
 *
 * @author Ricardo
 */
public class RssGoogleFeedBoot {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            // TODO code application logic here
            URL url = new URL("https://ajax.googleapis.com/ajax/services/feed/find?"
                    + "v=1.0&q=Official%20Google%20Blog&userip=INSERT-USER-IP");
            URLConnection connection = url.openConnection();
            connection.addRequestProperty("Referer", "http://www.eltiempo.com/economia/rss.xml");

            String line;
            StringBuilder builder = new StringBuilder();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }

            JSONObject json = new JSONObject(builder.toString());
            System.out.print(json.toString());
            // now have some fun with the results...
        } catch (Exception ex) {
            Logger.getLogger(RssGoogleFeedBoot.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
